﻿using MediatR;
using MS.Data.API.Write.Applicant.Command.RoleInfo;
using MS.Data.Domain;
using MS.Data.ErrorCode;
using MS.Data.Infratructrue.Istanbul;

namespace MS.Data.API.Write.Applicant.CommandHandel.RoleInfo
{
    public class AddRoleCommandHandel : IRequestHandler<AddRoleCommand, APIResult<int>>
    {
        IBaseRepository<Role> roleRep;


        public AddRoleCommandHandel(IBaseRepository<Role> roleRep)
        {
            this.roleRep = roleRep;

        }

        public async Task<APIResult<int>> Handle(AddRoleCommand request, CancellationToken cancellationToken)
        {

            request.role.CreaTime= DateTime.Now;

            await roleRep.Add(request.role);

            return new APIResult<int>()
            {
                code=APIEnum.添加成功,
                mes="",
                data=1
            };
        }
    }
}
